# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=cairo
pkgver=1.17.6
pkgrel=2
pkgdesc="A vector graphics library"
url="https://cairographics.org/"
arch="all"
options="!check"  # Recursive dependency on gtk+2.0 for check.
license="LGPL-2.0-or-later MPL-1.1"
depends_dev="
	$pkgname-tools
	fontconfig-dev
	freetype-dev
	libxext-dev
	libxrender-dev
	pixman-dev
	xcb-util-dev
	"
makedepends="$depends_dev
	expat-dev
	glib-dev
	gtk-doc
	libpng-dev
	meson
	zlib-dev
	"
subpackages="
	$pkgname-dbg
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-gobject
	$pkgname-tools
	"
source="https://gitlab.freedesktop.org/cairo/cairo/-/archive/$pkgver/cairo-$pkgver.tar.bz2
	musl-stacksize.patch
	fix-type1-subset-indexing.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

# secfixes:
#   1.17.4-r1:
#     - CVE-2019-6462
#   1.16.0-r2:
#     - CVE-2020-35492
#   1.16.0-r1:
#     - CVE-2018-19876

build() {
	abuild-meson \
		-Ddefault_library=both \
		-Dgtk_doc=true \
	output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

gobject() {
	pkgdesc="$pkgdesc (gobject bindings)"

	amove usr/lib/libcairo-gobject.so.*
}

tools() {
	pkgdesc="$pkgdesc (development tools)"

	amove usr/bin
	amove usr/lib/cairo/libcairo-trace.*
}

sha512sums="
1537b34ca49b853f4f60a7ceac0c1b878e7e2874f1ca3a37ab6ccbb704a37872314447016ad07b82312b302bb6df86b71265232a802ccdb9fb8cd18f211ff185  cairo-1.17.6.tar.bz2
86f26fe41deb5e14f553c999090d1ec1d92a534fa7984112c9a7f1d6c6a8f1b7bb735947e8ec3f26e817f56410efe8cc46c5e682f6a278d49b40a683513740e0  musl-stacksize.patch
fe9badbffceea378cab893f8a13f76e7c411bba18bab69a768ceda68b05357a94b41bb9f025d05f0ae7d1d324f0cdf98bf5a2c27b35db45f3fc5a70bfa091113  fix-type1-subset-indexing.patch
"
